package models
{
	public class RESTResponse
	{
		private var _response:XML		= null;
		
		public function RESTResponse(response:XML) {
			_response = response;
		}

		public function success() : Boolean {
			return !error() && !warning();
		}
		
		public function warning() : Boolean {
			return _response.warning.length() != 0;
		}
		
		public function error() : Boolean {
			return _response.error.length() != 0;
		}
		
		public function errorCode() : String {
			if(error()) {
				return _response.error.@code;
			}
			return "";
		}
		
		public function warningCode() : String {
			if(warning()) {
				return _response.warning.@code;
			}
			return "";
		}
		
		public function dataNode() : XML {
			return _response.data.children()[0];
		}
		
		public function data() : XMLList {
			return _response.data.children();
		}
	}
}